// customer-service.js
Page({
  // 拨打电话
  makePhoneCall() {
    wx.makePhoneCall({
      phoneNumber: '4001234567'
    })
  },

  // 复制邮箱
  copyEmail() {
    wx.setClipboardData({
      data: 'support@billiards.com',
      success: () => {
        wx.showToast({
          title: '邮箱已复制',
          icon: 'none'
        })
      }
    })
  },

  askQuestion(e) {
    const question = e.currentTarget.dataset.question
    const answers = {
      "订单状态": {
        text: "您可通过「我的订单」查看实时状态，包含：\n1. 待支付\n2. 已预约\n3. 已完成\n4. 已取消",
        related: ["取消订单", "申请发票"]
      },
      "取消预约": {
        text: "取消规则：\n• 2小时前免费取消\n• 1-2小时扣20%\n• 1小时内扣50%\n操作路径：「订单详情」→「取消预约」",
        related: ["退款说明", "重新预约"]
      },
      "支付问题": {
        text: "常见支付问题解决方案：\n1. 检查网络连接\n2. 确认支付额度\n3. 更换支付方式\n4. 联系银行确认",
        related: ["支付限额", "发票申请"]
      }
    }

    wx.showModal({
      title: question,
      content: answers[question].text,
      confirmText: '相关咨询',
      cancelText: '关闭',
      success: (res) => {
        if (res.confirm) {
          wx.showActionSheet({
            itemList: answers[question].related,
            success: (res) => {
              this.askQuestion({
                currentTarget: {
                  dataset: { question: answers[question].related[res.tapIndex] }
                }
              })
            }
          })
        }
      }
    })
  },
  // 打开在线聊天
  openOnlineChat() {
    wx.navigateTo({
      url: '/pages/chat/chat'
    })
  }
  
})
